Repository navigation
fix(authserver): one client-metadata validator for the admin API and /oauth2/register; token revocation in the body; docs match the server (#344) - #361
Merged
Conversation
…/oauth2/register; token revocation takes the token in the body; drop stored-status reporting views (#344) #344 part 3b, code (owner design, 2026-11-30): - D2: ClientMetadataValidator holds the rules both ways of registering a client share: grant types, authentication methods (#332), redirect and post-logout redirect URIs (absolute http/https, a host, no fragment; https only where espi.security.require-https-redirect-uris is set, #298), and scopes the client could be granted through its own grant types, by EspiGrantScopePolicy's token-time rule. SELF_REGISTRATION adds the RFC 7591 Third Party rules (/oauth2/register, unchanged); ADMINISTRATOR is the admin API's. Admin create and update now refuse a scope a client could never be given (they only logged a warning) and an authorization_code client with no redirect URI; an update is checked as the client it would save. - #360: DELETE /admin/oauth2/tokens/{tokenId} put the access token in the URL, which access logs keep. It is now POST /admin/oauth2/tokens/revoke with the token in a form body, as RFC 7009 sends it; a query string is refused. - #355 (D4): PostgreSQL V14 drops v_active_clients, v_security_monitoring, check_security_violations() and v_active_client_certificates, which counted a client on a timed suspension as active, and the partial index idx_v_active_clients_status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e server, and a test keeps them in step (#343) #344 part 3b, docs: - openapi.yaml describes every /admin/oauth2 endpoint the controllers serve (status, delete, token revocation of a client, POST /tokens/revoke) with the server's schemas: PagedClientResponse, ClientDetails, UpdateClientStatusRequest, the client API's error body, and the delete and revocation responses; the camelCase ClientListResponse / ClientResponse, the stale error, conflict, validation and rate-limit responses are gone, and the parts not checked against the server are marked so. No OIDC, opaque bearer tokens. - ClientManagementOpenApiTest checks the response schemas against the DTOs, that the spec lists exactly the controllers' admin endpoints, and that every $ref resolves. - API_DOCUMENTATION.md points to the one client API guide instead of a second, wrong copy; error formats, certificate clients, rate limiting and the non-existent SDKs are corrected. INTEGRATION_GUIDE.md: no certificate-client example, the registration rules shared since #344, an opaque token response without id_token. OAUTH2_CLIENT_MANAGEMENT_API.md: the shared rules, token revocation in the form body, 404 with no body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… checks only what it sets, underscore hosts, empty revoke body (#344) - ClientMetadataValidator refuses a null grant type, authentication method, response type or scope before any Set.of/List.of lookup (500 -> 400). - An update refuses a null or blank redirect URI before the client is built. - An update checks only the redirect URIs or scopes it sets, against the client's grant types (validateRedirectUris / validateScopes), so a client stored before the shared rules can still be renamed or changed. - A redirect URI whose host Java does not parse (a Docker service name with an underscore) is accepted; one with no host is still refused. - POST /admin/oauth2/tokens/revoke with an empty body answers its documented "token is required". - One AssertJ chain in createRefusesHttpWhereHttpsIsRequired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copes it sets (#344) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n revocation audited, host names, update errors name the API's fields (#344) - updateChecksOnlyWhatItSets uses the legacy client it builds (the update() helper re-stubbed the ordinary one) and checks the saved client keeps its legacy redirect URI and scope. - POST /admin/oauth2/tokens/revoke is audited as token_revoked with the signed-in administrator and the client's client_id, never the token. - A redirect URI host Java does not parse must be a host name (letters, digits, '_', '.', '-') with an optional numeric port; *, %20, ... and a:b:c are refused. - An update's redirect URIs and scopes are checked before the client is built, so removing every redirect URI gets the shared rule's message. - validateRedirectUris and validateScopes refuse a null grant type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n is audited (#344) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en is revoked, every revocation attempt is audited, stricter host names (#344) - POST /admin/oauth2/tokens/revoke reads the token's client before removing the authorization, so a failed read revokes nothing instead of answering 500 for a revocation that was done and not audited. - Every attempt is audited as token_revoked under the administrator: a 404 or a failure with success false. The client_id is "(unknown)" when the token or its client is not found, with the internal id kept in the data. The token is never recorded. - A host Java does not parse must be dot-separated labels that start and end with a letter or digit, not all digits, with an optional port 1-65535. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… attempt is audited (#344) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the host-name fallback is removed (#344) Owner design review of #361: the fallback that read the authority when Java found no host (for underscore names such as Docker services) was hand-rolled host parsing in security-sensitive code, and produced findings in two review rounds. Nothing in the repository uses an underscore host. A redirect URI's host is now the one java.net.URI parses (an RFC 1123 host name or an IP address); a Docker service is named with '-', not '_'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-sensitive code is filed, not fixed (#344) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 1, 2026
…ays so; host test under both policies (#344) - A redirect URI with an http(s) scheme and no host (e.g. an underscore host name) is refused with "(no host name: use letters, digits and '-', or an IP address)" instead of "(an absolute http or https URI)". - The host comment cites RFC 2396, which java.net.URI follows. - hostNamesPass runs under both policies; the port 0/99999/'port' cases, refused only for their underscore host, are removed (port ranges: #366). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erscore hosts refused in every guide (#344) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ost and the port; both refusal messages tested (#344) - A redirect URI with an http(s) scheme but no host java.net.URI accepts (an underscore host, a non-numeric port, ...) is refused with "(no valid host: check the host name (letters, digits, '-' and '.', or an IP address) and the port)". - Tests: a non-http(s) URI gets "(an absolute http or https URI)"; the no-host message for redirect and post-logout redirect URIs, under both policies. - espiRegistrationValidator javadoc: a host is required, an underscore host name is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ists host-name characters (#344) java.net.URI refuses some names made of the listed characters (a last label starting with a digit, a label ending with '-') and an unbracketed IPv6 address, so the list misled. The message is now "(no valid host: check the host name and the port)"; test case http://tp.1example/cb. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#344 part 3b, the last part, per the owner's design of 2026-11-30 (decision). Part 3a was PR #359.
Closes #344
Closes #343
Closes #355
Closes #360
D2: one client-metadata validator for the admin API and
/oauth2/registerClientMetadataValidatorholds the rules both ways of registering a client share:/oauth2/register)authorization_code(+refresh_token)authorization_code,client_credentials,refresh_tokenclient_secret_basic,client_secret_post,none(#332)client_secret_basicnoneonly) cannot useclient_credentialshttp://orhttps://, in every profileespi.security.require-https-redirect-urisis setauthorization_code; an absolute http(s) URI with a host and no fragment; https only where the flag is set (#298). Post-logout redirect URIs tooEspiGrantScopePolicy): administrative forclient_credentials, customer forauthorization_codeSELF_REGISTRATIONadds the Third Party's own limits (as before):authorization_codewith an optionalrefresh_token,response_typescode,client_secret_basic, and the ESPI Third Party scopes.ADMINISTRATORis the admin API's.invalid_redirect_uriorinvalid_client_metadata. The admin API answers 400invalid_request.utility_admin_portal) can still be renamed.DataCustodian_Admin_Accesson anauthorization_codeclient;authorization_codeclient with no redirect URI;#360: token revocation no longer puts the token in the URL
DELETE /admin/oauth2/tokens/{tokenId}is nowPOST /admin/oauth2/tokens/revokewithtokenin a form body, as RFC 7009's/oauth2/revokesends it. A request with a query string is 400, and the token is never looked up.#355 (D4): stored-status reporting objects dropped
PostgreSQL V14 drops the objects that counted a client on a timed suspension as active:
v_active_clients,v_security_monitoring(which also reported the retiredfailure_count) andv_active_client_certificates;check_security_violations();idx_v_active_clients_status.No code read them. The drops use no CASCADE, so anything depending on them would fail the migration rather than vanish. The MySQL V3–V6 scripts that create the same objects are
.disabled(#145) and must leave them out when they are re-enabled.#343: docs
openapi.yaml:/admin/oauth2endpoint the controllers serve, with the server's schemas:PagedClientResponse,ClientDetails,UpdateClientStatusRequest, the client API's error body, and the delete and revocation responses.ClientListResponse/ClientResponseand the stale 409, 422 and 429 responses are gone./userinfo, the OAuth endpoints) are marked so.ClientManagementOpenApiTestnow checks:/admin/oauth2endpoints the two controllers serve, read from their mapping annotations;$refresolves.API_DOCUMENTATION.md:INTEGRATION_GUIDE.md:tls_client_authexample;id_token.OAUTH2_CLIENT_MANAGEMENT_API.md:Upload_Admin_Accessin the example.Tests
ClientMetadataValidatorTest(33 tests): both policies, redirect-URI forms, the https flag, grantable scopes per grant type, grant types, methods, public clients, blank scopes, self-registration's limits, and printable messages.authorization_codeclient without a redirect URI, and a fragment;OAuthAdminControllerTest: the token is taken only from the form body; a query string or a body without a token is 400 and nothing is looked up.invalid_client_metadatarefusals.Code review
Round 1 (
/code-review high, whole PR): three important findings and three nits, all fixed in 6f4896b (docs: 2180605).[null]) was 500:Set.of/List.ofthrow oncontains(null)redirect_uris:[null]was 500: Spring's builder fails before the validator runsUpload_Admin_Access, acom.example.espi://redirect URI, http underprod) could not even be renamedhttp://third_party:9090/...) was refusedtoken is requiredassertThatcalls on one responseRound 2 (
/code-review xhigh, scoped to 6f4896b and 2180605): no new runtime bug; one test gap, one finding that predates this PR, four nits. All fixed in 1ac121f (docs: 4b03529).update()helper re-stubbed the ordinary onetoken_revokedwith the signed-in administrator and the client'sclient_id, never the token; testopenapi.yamlstill described the update re-checking the whole client*,%20,...,a:b:c)validateScopes/validateRedirectUrisskipped the null checkRound 3 (
/code-review high, scoped to 1ac121f and 4b03529): one real bug in round 2's audit change, one doc problem that predates it, three nits. All fixed in 48f38bd (docs: 78d733a).DELETE /clients/{clientId}/tokensdoesclient_idclient_idis(unknown)(the column is NOT NULL), the internal id is kept underregistered_client_id; testa..b,a.-b,1.2.3.999, ports0and99999token_revokedwithsuccessfalse, never the token; testsRound 3 found a real bug, so under CLAUDE.md the automated reviews stopped there and the owner reviewed the design.
Owner design review: the core design is kept: one shared validator, an update checks only what it sets, the token in the form body, locked and audited admin writes. One change: the host-name fallback (added for round 1's nit 4, refined in rounds 2 and 3) is removed in 47c1652. A redirect URI's host is now the one
java.net.URIparses (RFC 2396: a host name or an IP address); a Docker service is named with-, not_. Nothing in the repository used an underscore host. Follow-ups filed on #255: #363 (single-token revocation throughClientAdminService, with the row lock), #364 (validateUpdatein the validator), #365 (report clients that break the rules; fix the seeds). CLAUDE.md now says a nit that adds new behaviour in security-sensitive code is filed, not fixed in the same PR (b99b643).Round 4 (
/code-review high, scoped to 47c1652 and b99b643): no real bug; five nits and two findings that predate the round. Fixed in 91f4fb3 (docs: 1b67ca1) or filed.http://third_party:9090/cbwas refused as "(an absolute http or https URI)", which it isjava.net.URIfollows RFC 2396INTEGRATION_GUIDE.md,openapi.yamlandAPI_DOCUMENTATION.md0,99999andporttest cases were refused only for their underscore host;java.net.URIdoes no port range checkhttps://good.example@evil.example/cb,user:pw@) are acceptedFull AS suite after round 4: 742 tests, 0 failures (WSL, Docker).
Round 5 (
/code-review high, scoped to 91f4fb3 and 1b67ca1): no real bug; four nits and one stale javadoc that predates the round. All fixed in 6b9ed72.http://tp.example:port/cb):java.net.URIthen gives no host.from the host name charactersmyapp://,javascript:, a relative URI andftp://, under both policiesespiRegistrationValidatorjavadoc did not say a host is requiredFull AS suite after round 5: 747 tests, 0 failures (WSL, Docker).
Round 6 (
/code-review high, scoped to 6b9ed72): no real bug; one nit, fixed in 38ba1be, and one finding that predates this PR, filed.java.net.URIrefusestp.1exampleandtp-.example, and an IPv6 address without bracketshttp://tp.1example/cbinvalid_redirect_uri, which RFC 7591 defines forredirect_urisonlyFull AS suite after round 6: 748 tests, 0 failures (WSL, Docker).
Round 7 (
/code-review high, scoped to 38ba1be): no findings. No furthersrc/change, so under CLAUDE.md the review cycle ends here.🤖 Generated with Claude Code